import useRouteStore from "@/common/store/routerStore";

/**
 * 根据用户KEY权限，判断是否显示标签
 * 使用方式： <div  v-has-key="['sys_user_reset','sys_user_reset_pwd']" > AAA </div>
 */
export default {
    mounted(el, binding, vnode) {
        let value = binding.value
        // console.log(" value --", value)
        // console.log(" useRouteStore().menuFunction --", useRouteStore().menuFunction)

        if (value && value instanceof Array && value.length > 0) {
            const has = useRouteStore().menuFunction.some(e => {
                return value.includes(e.functionKey)
            })
            // console.log("KEY has --", has)
            if (!has) el.parentNode && el.parentNode.removeChild(el)
        } else {
            throw new Error("KEY 权限不存在")
        }
    }
}
